package com.ioufev.mqtt.utils;

import java.util.Arrays;

/*测试类无用*/
public class test {
    public static void main(String[] args) {
        // 示例十六进制字符串
        String hexString = "2c e400 0d00 0401 6c8e 2ce4 000c 0003 016b 8b";

        try {
            // 将十六进制字符串转换为字节数组
            byte[] byteArray = HexUtils.hexStringToByteArray(hexString);
            System.out.println("字节数组: " + Arrays.toString(byteArray));

            // 解析数据
            int index = 0; // 数据的起始索引
            float[] parsedData = DataParser.parseData(byteArray, index);

            // 打印解析结果
            System.out.println("温度: " + parsedData[0] + " °C");
            System.out.println("湿度: " + parsedData[1] + " %");
            System.out.println("二氧化碳: " + parsedData[2] + " ppm");
            System.out.println("甲醛: " + parsedData[3] + " mg/m³");
            System.out.println("TVOC: " + parsedData[4] + " mg/m³");
            System.out.println("PM2.5: " + parsedData[5] + " µg/m³");
            System.out.println("PM10: " + parsedData[6] + " µg/m³");
        } catch (IllegalArgumentException e) {
            System.err.println("处理失败: " + e.getMessage());
        }
    }
}
